<template>
  <a-modal
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-descriptions :title="formInfo.title">
      <a-descriptions-item label="客户编号">{{ formInfo.customerCode }}</a-descriptions-item>
      <a-descriptions-item label="客户姓名">{{ formInfo.customerName }}</a-descriptions-item>
      <a-descriptions-item label="性别">{{ formInfo.sex }}</a-descriptions-item>
      <a-descriptions-item label="婚姻状况">{{ formInfo.maritalStatus }}</a-descriptions-item>
      <a-descriptions-item label="民族">{{ formInfo.nation }}</a-descriptions-item>
      <a-descriptions-item label="出生日期">{{ formInfo.birthday }}</a-descriptions-item>
      <a-descriptions-item label="身份证号">{{ formInfo.idCard }}</a-descriptions-item>
      <a-descriptions-item label="照片路径">{{ formInfo.photoPath }}</a-descriptions-item>
      <a-descriptions-item label="卡号">{{ formInfo.cardNum }}</a-descriptions-item>
      <a-descriptions-item label="联系电话">{{ formInfo.tele }}</a-descriptions-item>
      <a-descriptions-item label="地址">{{ formInfo.addr }}</a-descriptions-item>
      <a-descriptions-item label="职业">{{ formInfo.occupation }}</a-descriptions-item>
      <a-descriptions-item label="单位名称">{{ formInfo.unitName }}</a-descriptions-item>
      <a-descriptions-item label="部门名称">{{ formInfo.deptName }}</a-descriptions-item>
      <a-descriptions-item label="班组名称">{{ formInfo.teamName }}</a-descriptions-item>
      <a-descriptions-item label="来源=1 前台创建=2 团检导入=3自助终端机=4 外网预约">{{ formInfo.source }}</a-descriptions-item>
      <a-descriptions-item label="vip标识">{{ this.$sysDictFilter(formInfo.vipFlag, 'vipFlag') }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ formInfo.createTime }}</a-descriptions-item>
      <a-descriptions-item label="系统编码">{{ formInfo.departCode }}</a-descriptions-item>
      <a-descriptions-item label="备注">{{ formInfo.remark }}</a-descriptions-item>
    </a-descriptions>
  </a-modal>
</template>

<script>
  import pick from 'lodash.pick'
  import { getAction } from '@/api/manage'

  export default {
    name: 'HealthCustomerView',
    components: {},
    data () {
      return {
        visible: false,
        confirmLoading: false,
        formInfo: {},
        url: {
          saveInfo: '/system/healthCustomer/save',
          getInfo: '/system/healthCustomer/info'
        }
      }
    },
    created () {
    },
    methods: {
      show (record) {
        this.formInfo = Object.assign({}, record)
        if (this.formInfo.id) {
          getAction(this.url.getInfo, { 'id': record.id }).then(res => {
            this.$nextTick(() => {
              this.formInfo = (pick(res.result.data
        , 'id'
        , 'customerCode'
        , 'customerName'
        , 'sex'
        , 'maritalStatus'
        , 'nation'
        , 'birthday'
        , 'idCard'
        , 'photoPath'
        , 'cardNum'
        , 'tele'
        , 'addr'
        , 'occupation'
        , 'unitName'
        , 'deptName'
        , 'teamName'
        , 'source'
        , 'vipFlag'
        , 'createTime'
        , 'departCode'
        , 'remark'
              ))
            })
          })
        }
        this.visible = true
      },
                                                                                                                                                                                                              // 确定
      handleSubmit () {
        this.visible = false
      },
      // 关闭
      handleCancel () {
        this.close()
      },
      close () {
        this.visible = false
      }
    }
  }
</script>
